% {\bf Left-handed grippers.}
% Measurements of the left- and right-hand gripping strengths of
% 10 left-handed writers are recorded.
% \begin{center}
% \begin{tabular}{|l|c|c|c|c|c|c|c|c|c|c|}
% \hline
% Person & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ \hline
% Left hand (X) & 140 & 90 & 125 & 130 & 95 & 121 & 85 & 97 & 131 & 110 \\ \hline
% Right hand (Y) & 138 & 87 & 110 & 132 & 96 & 120 & 86 & 90 & 129 & 100 \\ \hline
% \end{tabular}
% \end{center}
% 
% $\bullet$ Do the data provide strong evidence that people who write
% with left hand have a greater gripping strength in the left hand
% then they do in the right hand? 
close all
clear all

%==========
 lw = 2;  
 set(0, 'DefaultAxesFontSize', 16);
 fs = 16;
 msize = 6;
%==========



dataL =[ 140 , 90 , 125 , 130 , 95 , 121 , 85 , 97 , 131 , 110 ];
dataR =[ 138 , 87 , 110 , 132 , 96 , 120 , 86 , 90 , 129 , 100 ];
mm=mean(dataL - dataR)
%randperm(2)
data =[dataL; dataR];
means=[]; asl =0; N=10000;
for i = 1:N
    pdata=[];
    for j=1:10
        pairs = data(randperm(2),j);
        pdata = [pdata pairs];
    end
pdataL = pdata(1,:);
pdataR = pdata(2,:);
pmean=mean(pdataL - pdataR);
means= [means pmean];
asl = asl + (abs(pmean) > mm);
end


hist(means, 3*log(N))
hold on
%plot([mm mm],[0 2*N/(3*log(N))], 'k:','linewidth',8)
plot([mm mm],[0 600], 'w:','linewidth',5)

print -deps 'C:\NPBook\Bootstrap\permute2.eps'
asl = asl/N

